package cn.zl.rtsp.response.core;

import cn.zl.rtsp.RTPTask;
import cn.zl.rtsp.response.RTSPResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.DefaultHttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PlayRTSPResponse extends RTSPResponse {

    private static final Logger logger = LoggerFactory.getLogger(PlayRTSPResponse.class);

    public PlayRTSPResponse(ChannelHandlerContext context, DefaultHttpRequest request) {
        super(context, request);
    }

    @Override
    protected void write(StringBuilder builder) {
        builder.append("Range: npt=0.000-").append(R_N);
        builder.append("Session: ").append(session.getId()).append(R_N);
    }

    @Override
    public void after() {
        logger.info("启动发送数据任务");
        Thread thread = new Thread(new RTPTask(this.session.getRtpUdpSocket()));
        thread.start();
    }
}
